package com.spring.boot.rpc.rpc08;

import com.caucho.hessian.io.Hessian2Output;
import com.spring.boot.rpc.rpc00.User;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class HelloHessian {

    public static void main(String[] args) throws IOException {
        User u = new User(1,"xxx");
        byte[] bytes = HelloHessian.serialize(u);

    }

    public static byte[] serialize(Object o) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Hessian2Output output = new Hessian2Output(baos);
        output.writeObject(o);
        output.flush();
        byte[] bytes = baos.toByteArray();
        baos.close();
        output.close();
        return bytes;
    }



}
